home *** CD-ROM | disk | FTP | other *** search
/ Light ROM 1 / LIGHT-ROM 1 (Amiga Library Services)(1994).iso / ffdisks / d919.lha / TxtCvt / gettype.c next >
C/C++ Source or Header  |  1993-10-04  |  2KB  |  89 lines

  1. #include "txtcvt.h"
  2.  
  3. /*******************************
  4.     Check for type of inputfile
  5. ********************************/
  6.  
  7. int getfiletype(FILE *ifp)
  8. {
  9.     int filetype = NULL;
  10.     int r;
  11.     int c;
  12.  
  13.     c = fgetc(ifp);
  14.     if(c != EOF) {
  15.         switch (c) {
  16.             case 0x31 : {
  17.                 c = fgetc(ifp);
  18.                 if(c == 0xbe) {
  19.                     r = fseek(ifp, 96, SEEK_SET);
  20.                     if(r != -1)    {
  21.                         c = fgetc(ifp);
  22.                         if(c != EOF) {
  23.                             if(c == 0) {
  24.                                 c = fgetc(ifp);
  25.                                 if(c == 0) {
  26.                                     printf("Word 5.5\n");
  27.                                     filetype = DOSWORD;
  28.                                 }
  29.                                 else {
  30.                                     printf("Windows Write 3.1\n");
  31.                                     filetype = WINWRITE;
  32.                                 }
  33.                             }
  34.                             else {
  35.                                 printf("Windows Write 3.1\n");
  36.                                 filetype = WINWRITE;
  37.                             }
  38.                         }
  39.                     }
  40.                 }
  41.             }
  42.             case 0x5b : {
  43.                 c = fgetc(ifp);
  44.                 if(c == 0x76) {
  45.                     c = fgetc(ifp);
  46.                     if(c == 0x65) {
  47.                         c = fgetc(ifp);
  48.                         if(c == 0x72) {
  49.                             c = fgetc(ifp);
  50.                             if(c == 0x5d) {
  51.                                 printf("Ami Pro\n");
  52.                                 filetype = AMIPRO;
  53.                             }
  54.                         }
  55.                     }
  56.                 }
  57.             }
  58.             case 0x9b : {
  59.                 c = fgetc(ifp);
  60.                 if(c == 0xa5) {
  61.                     printf("WinWord 1.x\n");
  62.                     filetype = WINWORD1;
  63.                 }
  64.             }
  65.             case 0xdb : {
  66.                 c = fgetc(ifp);
  67.                 if(c == 0xa5) {
  68.                     printf("WinWord 2.0\n");
  69.                     filetype = WINWORD2;
  70.                 }
  71.             }
  72.             case 0xff : {
  73.                 c = fgetc(ifp);
  74.                 if(c == 0x57) {
  75.                     c = fgetc(ifp);
  76.                     if(c == 0x50) {
  77.                         c = fgetc(ifp);
  78.                         if(c == 0x43) {
  79.                             printf("WordPerfect 5.x\n");
  80.                             filetype = WORDPERFECT5;
  81.                         }
  82.                     }
  83.                 }
  84.             }
  85.         }
  86.     }
  87.     return(filetype);
  88. }
  89.